package com.olda.play.common.service.impl;

import com.olda.play.common.service.QiNiuService;
import com.olda.play.rpc.CommonResponseDto;
import com.olda.play.storage.QiNiuUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


@Service
@Api(tags = {"第三方凭证文档"}, description = "涉及七牛云等")
@RefreshScope
public class QiNiuServiceImpl implements QiNiuService {

    private static final Logger logger = LoggerFactory.getLogger(QiNiuServiceImpl.class);
    @Autowired
    private QiNiuUtil qiNiuUtil;

    /**
     * 生成七牛云客户端简单上传的凭证
     * @param
     * @return
     */
    @ApiOperation(value = "生成七牛云客户端简单上传的凭证(也就是说图片初次上传情况的凭证)")
    @RequestMapping(value = "/simpleupload",method = RequestMethod.GET,produces = "application/json;charset=UTF-8" )
    @ResponseBody
    @Override
    public CommonResponseDto<String> simpleupload() {
        /**
         * 参考文案
         * https://github.com/qiniu/java-sdk/blob/master/src/main/java/com/qiniu/util/Auth.java
         * https://developer.qiniu.com/kodo/manual/1206/put-policy
         */
//        return CommonResponseDto.success(qiNiuUtil.getQiNiuToken());
        return CommonResponseDto.success(qiNiuUtil.getQiNiuTokenRedisson());
    }
}
